﻿using SqlSugar;

namespace banyuetan_2_0.Model.Models
{
    /// <summary>
    /// 分类与文章对应关系表：多对多
    /// </summary>
    public class CategoryAndArticle
    {
        /// <summary>
        /// 主键
        /// </summary>
        [SugarColumn(IsNullable =false,IsPrimaryKey =true)]
        public int caId { get; set; }
        /// <summary>
        /// Category ID
        /// </summary>
        [SugarColumn(IsNullable =false)]
        public int cId { get; set; }
        /// <summary>
        /// 导航属性Category
        /// </summary>
        [Navigat(NavigatType.OneToOne,nameof(cId))]
        public Category Category { get; set; }  //此处不将导航属性List《Article》写到Category中的原因是，单独查询一个Category就带出其下所有的Article显得太没有必要，故还是采用手动方法，查找Articles先找到CategoryAndArticle中categoryid指定后的Articles集合，再根据ids去找到Articles集合。

        /// <summary>
        /// Author ID
        /// </summary>
        [SugarColumn(IsNullable =false)]
        public int aId { get; set; }
        /// <summary>
        /// 导航属性Author
        /// </summary>
        [Navigat(NavigatType.OneToOne, nameof(aId))]
        public Article Article { get; set; }
    }
}
